package com.my.yyr.dao.safty;

import com.my.yyr.dto.UserDto;
import com.my.yyr.model.Role;
import com.my.yyr.model.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserDao {
    //@Select("select * from sys_user")
    List<User> findUserList(UserDto userDto);

    @Insert("insert into sys_user(u_id,u_pwd,u_name,u_status) values(#{u_id},#{u_pwd},#{u_name},#{u_status})")
    int insertNewUser(UserDto userDto);

    @Select("select count(u_id) from sys_user where u_id = #{u_id}")
    boolean findUserId(String u_id);

    void deleteUsers(@Param("ids") String[] ids , @Param("status") String status);

    @Update("update sys_user set u_name = #{u_name} where u_id = #{u_id} and u_status = '00' ")
    void updateUser(UserDto userDto);

    int updteUserStatus(@Param("uid") String uid, @Param("status") String status);

    @Select("select ro_id,ro_name,ro_remark from sys_role")
    List<Role> findRoleList();

    @Select("select ro_id from sys_ur where u_id = #{uid}")
    List<String> findUserRoleIdList(String uid);

    @Delete("delete from sys_ur where u_id = #{u_id}")
    void deleteUserRoles(String u_id);

    void insertUserRoles(@Param("u_id") String u_id,@Param("roleIds") Integer[] roleIds);
}
